GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
GmPhysics Class Reference

Base interface class for Physics type plugins. More...

#include <gmPhysics.h>

Inheritance diagram for GmPhysics:
Collaboration diagram for GmPhysics:

Public Member Functions

 GmPhysics (GmSimulationData *simulation, QString id, QString description, const GmLogCategory &logger)
 Constructor.
 
virtual ~GmPhysics ()
 Virtual destructor.
 
virtual const char * pluginCategory () const
 Returns the plugin category.
 
virtual void printParameters (const GmLogCategory &logger)
 Asks the physics to print all of its parameters using the provided logger.
 
GmCellAccessorpropertyAccessor (GmCellMesh *mesh, QString stdPropertyName, QString msgDescription, LuaTable &table, Unit desiredUnit, bool required, int type=-1, int nlin=-1, int ncol=-1, bool canBeFunction=true, bool ignoreWarnings=false)
 An auxiliary function that given a property name, retrieves the accessor for that property.
 
GmCellAccessorextPropertyAccessor (GmCellMesh *mesh, QString stdPropertyName, QString msgDescription, LuaTable &table, Unit desiredUnit, bool required, int type=-1, int nlin=-1, int ncol=-1, bool canBeFunction=true, bool ignoreWarnings=false)
 Simmilar to propertyAccessor() but also looking for the requested property name in the set of element attributes.
 
GmDiscontinuityAccessordiscontinuityPropertyAccessor (GmDiscontinuitySet *discSet, QString stdPropertyName, QString msgDescription, LuaTable &table, Unit desiredUnit, bool required, int type=-1, int nlin=-1, int ncol=-1, bool ignoreWarnings=false)
 Simmilar to propertyAccessor() but looking for properties in a discontinuity set.
 
GmDiscontinuityAccessorextDiscontinuityPropertyAccessor (GmDiscontinuitySet *discSet, QString stdPropertyName, QString msgDescription, LuaTable &table, Unit desiredUnit, bool required, int type=-1, int nlin=-1, int ncol=-1, bool ignoreWarnings=false)
 Simmilar to extPropertyAccessor() but looking for properties/attributes in a discontinuity set.
 
- Public Member Functions inherited from GmPluginObject
 GmPluginObject (GmSimulationData *simulation, QString id, QString description, const GmLogCategory &logger)
 Constructor.
 
virtual ~GmPluginObject ()
 Destructor.
 
QString id () const
 Returns the object id.
 
QString description () const
 Returns the object description.
 
QString pluginTypeName () const
 Returns the hierarchical type name for the plugin object type. See also pluginName() and pluginType().
 
virtual const char * pluginName () const =0
 Returns a string identifying the plugin which implements this object. Should return the SAME string as the one read from the plugin information file in the pluginName field.
 
virtual const char * pluginType () const =0
 Returns the string identifying the plugin object type. Should return the SAME string as the one read from the plugin information file in the objectTypes table.
 
virtual bool loadPrivateData (LuaTable &table)=0
 Function called by the model loader to give the object acess to it's private parameters. Should return false only if the received parameter set makes the use of this object impossible.
 

Protected Member Functions

GmCellAccessorcellAttributeAccessor (GmCellMesh *mesh, QString stdAttributeName, QString msgDescription, LuaTable &table, Unit desiredUnit, bool required, int type=-1, int nlin=-1, int ncol=-1, int history=-1, bool canBeFunction=true, bool create=false, QString createFormat="", int createHistory=-1, bool ignoreWarnings=false)
 Similar to propertyAccessor() returning a cell attribute. The history parameter defines a restriction on the attribute history value (a -1 means that any history type is allowed). If the last parameter (create) is true, the attribute is required and if not found in the mesh, it will be created by the function (and its numeric format will be set to the value given by createFormat if not empty, using createHistory states)
 
GmCellAccessorcellDataAccessor (GmCellMesh *mesh, QString stdAttributeName, QString msgDescription, LuaTable &table, Unit desiredUnit, bool required, int type=-1, int nlin=-1, int ncol=-1, int history=-1, bool canBeFunction=true, bool ignoreWarnings=false)
 Similar to cellAttributeAccessor() but returning either a cell attribute or a state var. Can't be used to create new values.
 
GmValueAccessornodeAttributeAccessor (GmCellMesh *mesh, QString stdAttributeName, QString msgDescription, LuaTable &table, Unit desiredUnit, bool required, int type=-1, int nlin=-1, int ncol=-1, int history=-1, bool canBeFunction=true, bool create=false, QString createFormat="", int createHistory=-1, bool ignoreWarnings=false)
 Similar to propertyAccessor() returning a node attribute. The history parameter defines a restriction on the attribute history value (a -1 means that any history type is allowed). If the last parameter (create) is true, the attribute is required and if not found in the mesh, it will be created by the function (and its numeric format will be set to the value given by createFormat if not empty, using createHistory states)
 
GmValueAccessornodeDataAccessor (GmCellMesh *mesh, QString stdAttributeName, QString msgDescription, LuaTable &table, Unit desiredUnit, bool required, int type=-1, int nlin=-1, int ncol=-1, int history=-1, bool canBeFunction=true, bool ignoreWarnings=false)
 Similar to nodeAttributeAccessor() but returning either a node attribute or a state var. Can't be used to create new values.
 
GmBoundaryConditionAccessorboundaryAccessor (const GmBoundaryCondition *bc, QString stdPropertyName, QString msgDescription, Unit desiredUnit, bool required, int type=-1, int nlin=-1, int ncol=-1, bool canBeFunction=true, bool ignoreWarnings=false)
 An auxiliary function tha given a boundary condition property name, retrieves the accessor for that property, doing consistency checks in a similar way to those in propertyAccessor()
 
GmContactBoundaryConditionAccessorcontactAccessor (const GmContactBoundaryCondition *bc, QString stdPropertyName, QString msgDescription, Unit desiredUnit, bool required, int type=-1, int nlin=-1, int ncol=-1, bool canBeFunction=true, bool ignoreWarnings=false)
 An auxiliary function tha given a contact boundary condition property name, retrieves the accessor for that property, doing consistency checks in a similar way to those in propertyAccessor()
 
QString dofFromStateVar (const GmCellMesh *mesh, QString stdStateVarName, QString msgDescription, LuaTable &table, QVector< int > &dofList, Unit resultUnit, bool required, GmValueSetKind svType, int type=-1, int nlin=-1, int ncol=-1, bool ignoreWarnings=false)
 An auxiliary function that given a state var name, retrieves its degree of freedom and appends it to a list of degrees of freedom.
 
QString translateId (QString stdName, LuaTable &table) const
 Helper function to translate a data id from the values in a Lua translation table. Table might be invalid.
 
bool checkType (GmValueInfo *info, int type, int nlin, int ncol, bool required, bool ignoreWarnings, QString dataTypeMsg, QString msgDescription) const
 Helper function used by the accessor retrieval routines to check if the given info object respects the given type, nlin and ncol parameters. If not, emits error or warning messages according to the required and ignoreWarnings flags, including dataTypeMsg and msgDescription. Returns true on a match, false otherwise. Notice that checkType() will return true if type is -1.
 
bool checkFunction (GmValueInfo *info, bool canBeFunction, bool required, bool ignoreWarnings, QString dataTypeMsg, QString msgDescription) const
 Helper function used by the accessor retrieval routines to check if the given info object respects the given function filter. If not, emits error or warning messages according to the required and ignoreWarnings flags, including dataTypeMsg and msgDescription. Returns true on a match, false otherwise.
 
bool checkHistory (GmValueInfo *info, int history, bool required, bool ignoreWarnings, QString dataTypeMsg, QString msgDescription) const
 Helper function used by the accessor retrieval routines to check if the given info object respects the given history filter. If not, emits error or warning messages according to the required and ignoreWarnings flags, including dataTypeMsg and msgDescription. Returns true on a match, false otherwise.
 
GmValueInfocreateValueInfo (QString id, QString description, Unit desiredUnit, GmValueSetKind kind, int type, int nlin, int ncol, QString createFormat, int createHistory) const
 Helper function used to create a new value info object from standard accessor retrieval function arguments.
 
- Protected Member Functions inherited from GmPluginObject
virtual const GmLogCategorylogger () const
 Returns the internal logger used by the plugin to emmit messages.
 
GmSimulationDatasimulationData () const
 Returns a reference to the simulation data object keeping global simulation information.
 

Private Member Functions

GmCellAccessorpropertyAccessorAux (GmCellMesh *mesh, QString stdPropertyName, QString msgDescription, LuaTable &table, Unit desiredUnit, bool acceptsCellAttributes, bool required, int type, int nlin, int ncol, bool canBeFunction, bool ignoreWarnings)
 An auxiliary function that given a property name, retrieves the accessor for that property. Can also search for the accessor on element attributes if acceptsCellAttributes is true.

 
GmDiscontinuityAccessordiscontinuityPropertyAccessorAux (GmDiscontinuitySet *discSet, QString stdPropertyName, QString msgDescription, LuaTable &table, Unit desiredUnit, bool acceptsCellAttributes, bool required, int type, int nlin, int ncol, bool ignoreWarnings)
 An auxiliary function simmilar to that propertyAccessorAux() but getting accessors from a discontinuity set.
 

Detailed Description

Base interface class for Physics type plugins.

The class also features some utilitary protected functions to help in common tasks usually found in physcs modules

Constructor & Destructor Documentation

◆ GmPhysics()

GmPhysics::GmPhysics ( GmSimulationData * simulation,
QString id,
QString description,
const GmLogCategory & logger )

Constructor.

Parameters
simulationReference to the simulation object.
idPhysics id.
descriptionPhysics description.
loggerPlugin logger object used to emmit messages

Member Function Documentation

◆ cellAttributeAccessor()

GmCellAccessor * GmPhysics::cellAttributeAccessor ( GmCellMesh * mesh,
QString stdAttributeName,
QString msgDescription,
LuaTable & table,
Unit desiredUnit,
bool required,
int type = -1,
int nlin = -1,
int ncol = -1,
int history = -1,
bool canBeFunction = true,
bool create = false,
QString createFormat = "",
int createHistory = -1,
bool ignoreWarnings = false )
protected

Similar to propertyAccessor() returning a cell attribute. The history parameter defines a restriction on the attribute history value (a -1 means that any history type is allowed). If the last parameter (create) is true, the attribute is required and if not found in the mesh, it will be created by the function (and its numeric format will be set to the value given by createFormat if not empty, using createHistory states)

Keep in mind that the returned accessor will always point to the current state. To create an accessor for other states one can use the info object bound to the returned accessor to get the accessor name and call _mesh->cellValueAccessor() to get the accessor for a previous state.

When set to true, the ignoreWarnings flag prevents the emission of log messages when an optional property was not returned by a type problem.

◆ discontinuityPropertyAccessorAux()

GmDiscontinuityAccessor * GmPhysics::discontinuityPropertyAccessorAux ( GmDiscontinuitySet * discSet,
QString stdPropertyName,
QString msgDescription,
LuaTable & table,
Unit desiredUnit,
bool acceptsCellAttributes,
bool required,
int type,
int nlin,
int ncol,
bool ignoreWarnings )
private

An auxiliary function simmilar to that propertyAccessorAux() but getting accessors from a discontinuity set.

This is the worker function for both discontinuityPropertyAccessor() and extDiscontinuityPropertyAccessor(). See parameter description in GmPhysics::propertyAccessor().

◆ dofFromStateVar()

QString GmPhysics::dofFromStateVar ( const GmCellMesh * mesh,
QString stdStateVarName,
QString msgDescription,
LuaTable & table,
QVector< int > & dofList,
Unit resultUnit,
bool required,
GmValueSetKind svType,
int type = -1,
int nlin = -1,
int ncol = -1,
bool ignoreWarnings = false )
protected

An auxiliary function that given a state var name, retrieves its degree of freedom and appends it to a list of degrees of freedom.

If table is a valid Lua table, we look for a field in that table named with the value of stdStateVarName. If found, that name replaces the value of stdStateVarName.

After that, we look for a mesh state var with the requested name matching the specified type and restrictions. If found, all degrees of freedom associated to that state var are appended to the dofList and the function returns the name of the recovered state var. If not found and required is true, a message is written with the standard logger using msgDescription to clarify the missing state var. The function returns an empty string if no matching state var is found.

If required is false and the property is found but it doesn't match the restrictions, a waring message is printed. The available restrictions include specifying the required state var type (node based or cell based), data type (-1 means any type) and required data size for vectors (through nlin) or matrices (through nlin and ncol) and also that the state var unit can accept values expressed in the give resultUnit (which expresses the unit in which values will be calculated).

When set to true, the ignoreWarnings flag prevents the emission of log messages when an optional state var was not returned by a type problem.

◆ nodeAttributeAccessor()

GmValueAccessor * GmPhysics::nodeAttributeAccessor ( GmCellMesh * mesh,
QString stdAttributeName,
QString msgDescription,
LuaTable & table,
Unit desiredUnit,
bool required,
int type = -1,
int nlin = -1,
int ncol = -1,
int history = -1,
bool canBeFunction = true,
bool create = false,
QString createFormat = "",
int createHistory = -1,
bool ignoreWarnings = false )
protected

Similar to propertyAccessor() returning a node attribute. The history parameter defines a restriction on the attribute history value (a -1 means that any history type is allowed). If the last parameter (create) is true, the attribute is required and if not found in the mesh, it will be created by the function (and its numeric format will be set to the value given by createFormat if not empty, using createHistory states)

Keep in mind that the returned accessor will always point to the current state. To create an accessor for other states one can use the info object bound to the returned accessor to get the accessor name and call _mesh->nodeValueAccessor() to get the accessor for a previous state.

When set to true, the ignoreWarnings flag prevents the emission of log messages when an optional attribute was not returned by a type problem.

◆ pluginCategory()

virtual const char * GmPhysics::pluginCategory ( ) const
inlinevirtual

Returns the plugin category.

Implements GmPluginObject.

◆ printParameters()

void GmPhysics::printParameters ( const GmLogCategory & logger)
virtual

Asks the physics to print all of its parameters using the provided logger.

The default implementation logs the data, as seen through the access interface;

Implements GmPluginObject.

◆ propertyAccessor()

GmCellAccessor * GmPhysics::propertyAccessor ( GmCellMesh * mesh,
QString stdPropertyName,
QString msgDescription,
LuaTable & table,
Unit desiredUnit,
bool required,
int type = -1,
int nlin = -1,
int ncol = -1,
bool canBeFunction = true,
bool ignoreWarnings = false )
inline

An auxiliary function that given a property name, retrieves the accessor for that property.

If table is a valid Lua table, we look for a field in that table named with the value of stdPropertyName. If found, that name replaces the value of stdPropertyName.

After that, we look for a mesh property with the requested name matching the specified type and function restrictions. If found that accessor is the returned value, otherwise the function returns NULL. If not found and required is true, a message is written with the standard logger using msgDescription to clarify the missing property.

If required is false and the property is found but it doesn't match the restrictions, a warning message is printed. The available restrictions include specifying the required data type (-1 means any type) and required data size for vectors (through nlin) or matrices (through nlin and ncol). The canBeFunction restriction can be used to disallow properties that might be represented by user functions.

When set to true, the ignoreWarnings flag prevents the emission of log messages when an optional property was not returned by a type problem.

◆ propertyAccessorAux()

GmCellAccessor * GmPhysics::propertyAccessorAux ( GmCellMesh * mesh,
QString stdPropertyName,
QString msgDescription,
LuaTable & table,
Unit desiredUnit,
bool acceptsCellAttributes,
bool required,
int type,
int nlin,
int ncol,
bool canBeFunction,
bool ignoreWarnings )
private

An auxiliary function that given a property name, retrieves the accessor for that property. Can also search for the accessor on element attributes if acceptsCellAttributes is true.

This is the worker function for both propertyAccessor() and extPropertyAccessor(). See parameter description in GmPhysics::propertyAccessor().


The documentation for this class was generated from the following files: